{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from pathlib import Path\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "from tempfile import TemporaryDirectory"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import suite2p"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**IMPORTANT**: Before you run the cells below, make sure you've downloaded the test data. You can find instructions on how to download test data using dvc [here](https://suite2p.readthedocs.io/en/latest/developer_doc.html)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'data_path': ['../data/test_data'],\n",
       " 'save_path0': 'D:\\\\Temp\\\\tmp1p5ak5hx',\n",
       " 'tiff_list': ['input_1500.tif']}"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "db = {\n",
    "    'data_path': ['../data/test_data'],\n",
    "    'save_path0': TemporaryDirectory().name,\n",
    "    'tiff_list': ['input_1500.tif'],\n",
    "}\n",
    "db"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'data_path': ['../data/test_data'], 'save_path0': 'D:\\\\Temp\\\\tmp1p5ak5hx', 'tiff_list': ['input_1500.tif']}\n",
      "tif\n",
      "** Found 1 tifs - converting to binary **\n",
      "time 1.45 sec. Wrote 1500 tiff frames to binaries for 1 planes\n",
      ">>>>>>>>>>>>>>>>>>>>> PLANE 0 <<<<<<<<<<<<<<<<<<<<<<\n",
      "NOTE: not registered / registration forced with ops['do_registration']>1\n",
      "      (no previous offsets to delete)\n",
      "----------- REGISTRATION\n",
      "registering 1500 frames\n"
     ]
    }
   ],
   "source": [
    "ops = suite2p.run_s2p(db=db)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(296, 65536)"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "op = ops[0]\n",
    "masks = op['neuropil_masks']\n",
    "masks.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x1e43dd19948>"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAQYAAAD8CAYAAACVSwr3AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+j8jraAAARrUlEQVR4nO3df5TVdZ3H8edrBhgaVIL4EQIK6qhAKdJEmGW2lhLtBnbSQ1stnVxJxU4mecI6m9VZ9/QL7VRrSqnRrsGyoUfOmqZx2i0VgcFQ+REwIukAQWaKv/g1894/5otd+NyZucy9d+6dej3OmXPvfO7n+72v+ep5cb/fe7/fq4jAzCxXTaUDmFn1cTGYWcLFYGYJF4OZJVwMZpZwMZhZomzFIGmqpE2SmiXNK9fzmFnpqRyfY5BUC2wG3g+0AKuBj0bEhpI/mZmVXLleMUwGmiNia0TsBxYD08v0XGZWYn3KtN6RwLM5v7cA7+hocj/VRX8GlCmKmQG8xJ+fi4ihhcwtVzEoz9hh+yySZgOzAfpTzzt0fpmimBnAL+Nnvy90brl2JVqA0Tm/jwJ25E6IiAUR0RgRjX2pK1MMM+uOchXDaqBB0lhJ/YCZwLIyPZeZlVhZdiUi4qCkq4BfALXA7RGxvhzPZWalV65jDETEz4Gfl2v9ZlY+/uSjmSVcDGaWcDGYWcLFYGYJF4OZJVwMZpZwMZhZwsVgZgkXg5klXAx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SlswLvov0l9hPA2uxnWrVt105ylmyb+pOPZpao9K6EmVUhF4OZJVwMZpZwMZhZwsVgZgkXg5klXAxmlnAxmFni/wEiKCyqrMV8ZQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "aa = masks.reshape(masks.shape[0], op['Ly'], op['Lx'])\n",
    "plt.imshow(aa[6])"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "suite2p",
   "language": "python",
   "name": "suite2p"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
